﻿using System.Xml.Serialization;
using PrearrangedChaos.AgileZen.Service.Rest;

namespace PrearrangedChaos.AgileZen.Service.Model
{
    [XmlType(AnonymousType = true)]
    [XmlRootAttribute(ElementName = "comment", Namespace = "", IsNullable = false)]
    [ZenRestRequest("projects/{ProjectId}/stories/{StoryId}/comments/{CommentId}")]
    public class CommentUpdater : ModelBase, ICommentUpdater
    {
        private string _text;

        /// <remarks/>
        [XmlElement(ElementName = "text")]
        public string TextXmlElement
        {
            get { return _text; }
            set
            {
                if (!string.IsNullOrEmpty(value))
                    _text = value;
                else
                    _text = null;

                this.Unmodified("text");
            }
        }

        [XmlIgnore]
        public string Text
        {
            get { return _text; }
            set
            {
                if (_text == value)
                    return;

                _text = value;
                this.Modified("text");
            }
        }

        public bool TextXmlElementSpecified { get { return this.IsModified("text"); } }
    }
}